package com.example.base_kotlin_xml.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter4.BaseQuickAdapter
import com.example.base_kotlin_xml.databinding.ItemMainListAdapterBinding

/**
 * @Author jiangKunKun
 * @CreateDate 2025/7/24
 * @Description
 * @SpittingGrooves
 */
class MainListAdapter : BaseQuickAdapter<String, MainListAdapter.VH>() {

    // 自定义ViewHolder类
    class VH(
        parent: ViewGroup,
        val bind: ItemMainListAdapterBinding = ItemMainListAdapterBinding.inflate(
            LayoutInflater.from(parent.context), parent, false
        ),
    ) : RecyclerView.ViewHolder(bind.root)

    override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH {
        // 返回一个 ViewHolder
        return VH(parent)
    }

    override fun onBindViewHolder(
        holder: VH,
        position: Int,
        item: String?
    ) {
        holder.bind.btnMainItem.text = item
    }

}